<template>
  <div>
    <Panel title="市政补贴配置">
         <ModifyForm
        slot="body"
        :editColumn="editColumn"
        :temporaryData='temporaryData'
        labelWidth="150px"
        :updateData="updateData"
      >
        <p
          slot="title"
        ></p>
      </ModifyForm>
    </Panel>
  </div>
</template>
<script>
import Panel from "@/components/Panel";
import ModifyForm from "@/components/ModifyForm";
import ModalPanel from "@/components/ModalPanel";
import FileUpload from '@/components/FileUpload';
import request from "@/tools/request";

export default {
  naem:'governmentConfig',
  components: {
    FileUpload,
    Panel,
    ModalPanel,
    ModifyForm
  },
  data() {
    return {
     configValue:"",
      editorOption: {},
      typeList: [],
      temporaryData: {
        coverImg: [],
        publishStatus: false
      },
      editColumn: [
        {
          name: "推送百分比(0-1)",
          prop: "ratio",
          type: "text",
          width:24,
          required: true
        },
      ],
    };
  },
  computed: {
 

  },
  methods: {
   async updateData(values) {
     const { ratio } = values
     if(Number(ratio) >1 || Number(ratio) < 0 || isNaN(Number(ratio)) ){
         this.$message.error('请输入0-1范围内的数字')
         return false
     } 
     let res = await request({
        url: '/subsidy/set/update',
        method: "POST",
        data: { ratio }
      });
      if(res.code !==0 ) return
      this.$message.success('编辑成功')
      this.$router.go(-1)
    },
    async fetchData(id){
      let { info } = await request({
        url: "/subsidy/set/info",
        method: "GET",
        data: {}
      });
      this.temporaryData = info
    }
  },
  created() {
    this.fetchData()
  }
};
</script>

<style lang='scss' module>

</style>